import java.awt.image.BufferedImage
import java.io.File
import javax.imageio.ImageIO

/**
 * 对图片进行缩放
 */
fun main(args: Array<String>) {
    val scale:Float=(4.0/3.0).toFloat()
    File("src/main/resources/img").listFiles().forEach {
        var img=ImageIO.read(it)
        var newWidth:Int=(img.width*scale).toInt()
        var newHeight:Int=(img.height*scale).toInt()

        println("name:${it.name},scale:$scale,width:${newWidth},height:${newHeight},ext:${it.extension}")
        var buffer=BufferedImage(newWidth,newHeight,BufferedImage.TYPE_INT_ARGB)
        buffer.createGraphics().drawImage(img,0,0,newWidth,newHeight,null)
        ImageIO.write(buffer,it.extension,it)
    }
}